package com.cn.logback;

import org.slf4j.LoggerFactory;
import org.slf4j.Logger;

public class LogbackTest {
    //创建日志记录器实例
    private static final Logger logger = LoggerFactory.getLogger(LogbackTest.class);

    public static void main(String[] args) {
        // 获取当前程序的工作目录
        String currentDir = System.getProperty("user.dir");
        // 输出当前目录
        System.out.println("当前工作目录：" + currentDir);
        //trace < DEBUG < INFO < WARN < ERROR < FATAL
        //输入大于或等于该级别的日志
        logger.debug("This is a debug message");
        logger.info("This is an info message");
        logger.warn("This is a warn message");
        logger.error("This is an error message");

        try {
            int i = 10 / 0;
        } catch (Exception e) {
            logger.error("An exception occurred");
            throw new RuntimeException(e);
        }
    }

}
